<?php

namespace App\Http\Requests\client;

use App\Http\ValidateResult;
use Illuminate\Support\Facades\Validator;

trait BannerRequest
{
    public static function add_check(array $params): ValidateResult {
        $validator = Validator::make($params, [
            'title' => 'required',
            'picture_url' => 'required',
//            'link_url' => 'required',
            'status' => 'required',
        ], [
            'title.required' => '请填写标题',
            'picture_url.required' => '请上传图片',
//            'link_url.required' => '请填写跳转链接',
            'status.required' => '请选择是否生效',
        ]);

        if ($validator->fails()) {
            return ValidateResult::error($validator->errors()->first());
        }
        return ValidateResult::correct();
    }

}
